<?php
namespace backend\modules\admin\controllers;

use Yii;
//use backend\modules\mobo\models\BackendMenu;
use yii\base\InvalidParamException;
use yii\web\BadRequestHttpException;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;

use backend\models\Admin;
use backend\base\BaseBackendController;
use yii\web\NotFoundHttpException;

use yii\helpers\Security;

use submodule\models\Models;
use submodule\models\ModelsField;
use common\components\Tree;
use base\YiiMobo;



class IndexController extends \submodule\base\BaseSubmodelController
{

	public function init(){
		
		parent::init();

		
		$this->submodel->data_tablename = false;

	}


    public function submodelSaveCallback($id, $data){
        //Admin::findByUsername(yii::$app->user->identity->username);
		$user = $this->action->id == 'create' ? new Admin : Admin::findOne($id);
		if ($data[2]['password']) {
			$user->setAttributes($data[1]);
			$user->setPassword($data[2]['password']);
			$user->generateAuthKey();
			if($user->save()){
				$this->OperTips('/admin/index');
				exit;
			}else{
			    echo 'error';
			    exit;
			}
		}
		
	}
    


}
